<template>
	<view class="shopping">
		<Navbar>
			<text>江湖商店</text>
			<template #right>
				<view class="nav_right" @click="router('/pages/shopping/my_order?type=1')">
					<image :src="`${baseImageUrl}/add/order.png`"></image>
					<text>我的订单</text>
				</view>
			</template>
		</Navbar>
		<scroll-view scroll-y class="scroll_view" @scrolltolower="loadmore">
			<view class="list">
				<view class="item" v-for="item in list" @click="router(`/pages/shopping/deta?id=${item.id}`)">
					<image :src="item.cover" class="cover"></image>
					<view class="item_view">
						<view class="name">{{item.name}}</view>
						<view class="desc">{{item.synopsis}}</view>
						<view class="price">
							<view v-if="item.price>0">
								<text class="unit">￥</text>
								<!-- <image :src="`${baseImageUrl}/common/gy.png`"></image> -->
								<text>{{item.price}}</text>
							</view>
							<view v-if="item.price_silver>0">
								<!-- <image :src="`${baseImageUrl}/add/s1.png`"></image> -->
								<image :src="`${baseImageUrl}/common/gy.png`"></image>
								<text>{{item.price_silver}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="loadmore_status" :color="$store.state.loadmoreColor"
				:lineColor="$store.state.loadmoreColor" line @loadmore="loadmore" />
		</scroll-view>
	</view>
</template>

<script>
	import {
		shopProductLists
	} from '@/request/api.js';
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			async getList() {
				let {
					list
				} = await shopProductLists({
					page: this.page,
					limit: this.limit
				});
				this.last_page = list.last_page;
				list = list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];
				this.loadmore_status = this.last_page == this.page ? 'nomore' : 'loadmore';
			},
			loadmore() {
				if (this.page < this.last_page) {
					this.page++;
					this.getList();
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.shopping {
		height: 100vh;
		background: #29170D;

		.nav_right {
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 36rpx;
				height: 36rpx;
			}

			text {
				color: #FFFFFF;
				font-size: 20rpx;
				font-weight: 400;
				font-family: LiSu;
			}
		}

		.scroll_view {
			width: 100%;
			height: calc(100vh - #{$navbarHeight});
			padding: 90rpx 60rpx 20rpx;
			box-sizing: border-box;
			background: url(#{$baseImageUrl}/add/bg1.png) no-repeat;
			background-size: 100% 100%;
			position: relative;

			.list {
				width: 100%;
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.item {
					width: 300rpx;
					border-radius: 10rpx;
					margin-bottom: 20rpx;
					box-shadow: 0px 0px 7rpx 0px #EEEEEE;
					background: #FCF1E4;
					overflow: hidden;

					.cover {
						width: 300rpx;
						height: 300rpx;
					}

					.item_view {
						width: 100%;
						height: 200rpx;
						padding: 20rpx;
						box-sizing: border-box;
						display: flex;
						flex-direction: column;
						justify-content: space-between;

						.name {
							color: #494338;
							font-size: 26rpx;
							font-weight: bold;
						}

						.desc {
							color: #494338;
							font-size: 24rpx;
						}

						.price {
							display: flex;
							align-items: center;
							justify-content: space-between;

							&>view {
								display: flex;
								align-items: center;

								.unit {
									color: #494338;
									font-size: 24rpx;
									font-weight: 400;
									font-family: LiSu;
								}

								image {
									width: 38rpx;
									height: 38rpx;
								}

								text {
									color: #494338;
									font-size: 32rpx;
									font-weight: 400;
									font-family: LiSu;
									padding-left: 6rpx;
									box-sizing: border-box;
								}
							}
						}
					}
				}
			}
		}
	}
</style>